package tw.com.hitevision.whiteboard.android.stateFile;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

public class GsonInstance {
    private static Gson gsonInstance;
    private static Gson gsonCustomInstance;

    public static Gson getGsonInstance() {
        if (gsonInstance == null) {
//            gsonInstance = new Gson();
            GsonBuilder gsonBuilder = new GsonBuilder();
            gsonBuilder.serializeSpecialFloatingPointValues();
            gsonInstance = gsonBuilder.create();
        }

        return gsonInstance;
    }

    public static Gson getGsonCustomInstance() {
        if (gsonCustomInstance == null) {
//            gsonCustomInstance = new GsonBuilder().registerTypeAdapter(BaseStateFile.class, new BaseStateFileAdapter()).create();
            GsonBuilder gsonBuilder = new GsonBuilder();
            gsonBuilder.serializeSpecialFloatingPointValues();
            gsonCustomInstance = gsonBuilder.registerTypeAdapter(BaseStateFile.class, new BaseStateFileAdapter()).create();
        }

        return gsonCustomInstance;
    }

}
